<?php
include('inc_head.php');
$tag=$wu->request_string('tag');
if(!$tag) 		die('参数有误');
$id=$wu->request_int('id');
$itemid=$wu->request_int('itemid');
$data=to_array_keys('Title','CatalogID','Content','ImageURL');
if($id){
	$data=$db->fetch_row("select * from tgeneralarticle where ID=$id");	
}
if($wu->request_string("act")=='save'){
	$m=new module('tgeneralarticle');
	$dm->param('Title','string','标题未填写');
	$dm->param('CatalogID','int');
	$dm->param('Content','string','内容未填写');
	$dm->param('ImageURL','string');
	if($id){
		$wu->redirect($this->dm->update($id)?'编辑成功':$this->dm->get_error(),'article_list.php?tag='.$tag.($itemid?"&itemid=$itemid":''));
	}else{
		$this->dm->data('ExTags','string',$tag);
		if($itemid) $this->dm->data('ItemID','int',$itemid);
		$wu->redirect($this->dm->insert()?'新增成功':$this->dm->get_error(),'article_list.php?tag='.$tag.($itemid?"&itemid=$itemid":''));
	}
}
?>
<form action="#" method="post" >
<h1>编辑文章</h1>
<table cellpadding="0" cellspacing="0">
    <tr><td>标题</td><td><input type="text" name="Title" size="15" value="<?php echo $data['Title']; ?>" /><span class="help-block">长度不超过15个汉字.</span></td></tr>
    <tr><td>所属分类</td><td><select name="CatalogID"><?php echo $biz->get_generaltree($data['CatalogID'],'tgeneralcatalog',$tag); ?></select></td></tr>
    <tr><td>配图：</td><td><?php echo get_fileinput('ImageURL',$data['ImageURL']); ?></td></tr>
    <tr><td>内容</td><td><textarea name="Content" cols="120" rows="15" class="editor"><?php echo $data['Content']; ?></textarea></td></tr>
    <tr><td><input type="submit" value="保存" /><input type="reset" class="btn" value="重置" /></td></tr>
</table>
<input type="hidden" name="act" value="save" />
</form>
<?php
	include('inc_foot.php');
?>